package factory;

import dao.PetDao;

public class PetDaoFactory {
    // 此默认名称可以通过读取properties配置文件进行修改
    public static String defaultBeanName = "petDaoOracleIImpl";

    /*负责根据名称获取对应的PetDao实现对象*/
    public static PetDao getInstance(String beanName)
    {
        PetDao petDao;
        switch (beanName){
            case "petDaoMySQLImpl":
                petDao = new dao.impl.PetDaoMySQLImpl();
                break;
            case "petDaoOracleIImpl":
                petDao = new dao.impl.PetDaoOracleIImpl();
                break;
            default:
                throw new RuntimeException("未找到'"+beanName+"'对应的对象");
        }
        return petDao;
    }
}
